//package com.erp.user.service.impl;
//
//import cn.hutool.core.bean.BeanUtil;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.erp.user.domain.ErpPromotionCommissionLog;
//import com.erp.user.domain.bo.ErpPromotionCommissionLogBo;
//import com.erp.user.domain.vo.ErpPromotionCommissionLogVo;
//import com.erp.user.mapper.ErpPromotionCommissionLogMapper;
//import com.erp.user.service.IErpPromotionCommissionLogService;
//import com.ruoyi.common.core.domain.PageQuery;
//import com.ruoyi.common.core.utils.oldUtils.StringUtils;
//import com.ruoyi.common.core.web.oldPage.TableDataInfo;
//import lombok.RequiredArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.math.BigDecimal;
//import java.util.Collection;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
///**
// * 推广提成日志Service业务层处理
// *
// * @author erp
// * @date 2023-08-01
// */
//@RequiredArgsConstructor
//@Service
//public class ErpPromotionCommissionLogServiceImpl implements IErpPromotionCommissionLogService {
//
//    private final ErpPromotionCommissionLogMapper baseMapper;
//
//    /**
//     * 查询推广提成日志
//     */
//    @Override
//    public ErpPromotionCommissionLogVo queryById(Long id){
//        return baseMapper.selectVoById(id);
//    }
//
//    /**
//     * 查询推广提成日志列表
//     */
//    @Override
//    public TableDataInfo<ErpPromotionCommissionLogVo> queryPageList(ErpPromotionCommissionLogBo bo, PageQuery pageQuery) {
//        LambdaQueryWrapper<ErpPromotionCommissionLog> lqw = buildQueryWrapper(bo);
//        Page<ErpPromotionCommissionLogVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
//        return TableDataInfo.build(result);
//    }
//
//    /**
//     * 查询推广提成日志列表
//     */
//    @Override
//    public List<ErpPromotionCommissionLogVo> queryList(ErpPromotionCommissionLogBo bo) {
//        LambdaQueryWrapper<ErpPromotionCommissionLog> lqw = buildQueryWrapper(bo);
//        return baseMapper.selectVoList(lqw);
//    }
//
//    private LambdaQueryWrapper<ErpPromotionCommissionLog> buildQueryWrapper(ErpPromotionCommissionLogBo bo) {
//        Map<String, Object> params = bo.getParams();
//        LambdaQueryWrapper<ErpPromotionCommissionLog> lqw = Wrappers.lambdaQuery();
//        lqw.eq(bo.getComUserId() != null, ErpPromotionCommissionLog::getComUserId, bo.getComUserId());
//        lqw.eq(bo.getAmount() != null, ErpPromotionCommissionLog::getAmount, bo.getAmount());
//        lqw.eq(bo.getInfoUserId() != null, ErpPromotionCommissionLog::getInfoUserId, bo.getInfoUserId());
//        lqw.eq(bo.getUserType() != null, ErpPromotionCommissionLog::getUserType, bo.getUserType());
//        lqw.eq(bo.getRecommendTime() != null, ErpPromotionCommissionLog::getRecommendTime, bo.getRecommendTime());
//        lqw.eq(StringUtils.isNotBlank(bo.getUserCode()), ErpPromotionCommissionLog::getUserCode, bo.getUserCode());
//        lqw.eq(bo.getIsDivide() != null, ErpPromotionCommissionLog::getIsDivide, bo.getIsDivide());
//        lqw.eq(StringUtils.isNotBlank(bo.getOrderNo()), ErpPromotionCommissionLog::getOrderNo, bo.getOrderNo());
//        return lqw;
//    }
//
//    /**
//     * 新增推广提成日志
//     */
//    @Override
//    public Boolean insertByBo(ErpPromotionCommissionLogBo bo) {
//        ErpPromotionCommissionLog add = BeanUtil.toBean(bo, ErpPromotionCommissionLog.class);
//        validEntityBeforeSave(add);
//        boolean flag = baseMapper.insert(add) > 0;
//        if (flag) {
//            bo.setId(add.getId());
//        }
//        return flag;
//    }
//
//    /**
//     * 修改推广提成日志
//     */
//    @Override
//    public Boolean updateByBo(ErpPromotionCommissionLogBo bo) {
//        ErpPromotionCommissionLog update = BeanUtil.toBean(bo, ErpPromotionCommissionLog.class);
//        validEntityBeforeSave(update);
//        return baseMapper.updateById(update) > 0;
//    }
//
//    /**
//     * 保存前的数据校验
//     */
//    private void validEntityBeforeSave(ErpPromotionCommissionLog entity){
//        //TODO 做一些数据校验,如唯一约束
//    }
//
//    /**
//     * 批量删除推广提成日志
//     */
//    @Override
//    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
//        if(isValid){
//            //TODO 做一些业务上的校验,判断是否需要校验
//        }
//        return baseMapper.deleteBatchIds(ids) > 0;
//    }
//
//    /**
//     * 创建推广提成日志
//     * @param comUserId---提成用户id
//     * @param amount--提成金额
//     * @param infoUserId--被推广用户id
//     * @param userType 被推广用户类型（1分公司 2代理 3个人）
//     * @param recommendTime 推荐时间
//     * @param userCode 推荐客户编码
//     * @param isDivide 是否分佣 0否 1是
//     * @param orderNo 订单号
//     * @return
//     */
//    @Override
//    public Boolean insertPromotionCommissionLog(Long comUserId, BigDecimal amount, Long infoUserId, Integer userType, Date recommendTime, String userCode, Integer isDivide, String orderNo){
//        ErpPromotionCommissionLog entity=new ErpPromotionCommissionLog();
//        entity.setComUserId(comUserId);  //提成用户id
//        entity.setAmount(amount); //提成金额
//        entity.setInfoUserId(infoUserId); //被推广用户id
//        entity.setUserType(userType); //被推广用户类型（1分公司 2代理 3个人）
//        entity.setRecommendTime(recommendTime); //推荐时间
//        entity.setUserCode(userCode); //推荐客户编码
//        entity.setIsDivide(isDivide); //是否分佣 0否 1是
//        entity.setOrderNo(orderNo); //订单号
//        return baseMapper.insert(entity) > 0;
//    }
//
//
//
//}
